Addressed comments

Prathyush Thota 9 years ago
parent
commit
96813bd089
1 changed files with 7 additions and 9 deletions
  1. 7 9
      app/models/agents/boxcar_agent.rb

+ 7 - 9
app/models/agents/boxcar_agent.rb

@@ -13,9 +13,9 @@ module Agents
13 13
       The access token is available on general "Settings" screen of Boxcar iOS
14 14
       app or from Boxcar Web Inbox settings page.
15 15
 
16
-      Please provide the access token as `user_credentails` in `options` or create a
17
-      `boxcar_api_key` credential. The value in `user_credentials` will be considered if
18
-      specified in both places.
16
+      Please provide your access token in the `user_credentials` option. If
17
+      you'd like to use a credential, set the `user_credentials` option to `{%
18
+      credential CREDENTIAL_NAME %}`.
19 19
 
20 20
       Options:
21 21
 
@@ -43,8 +43,7 @@ module Agents
43 43
     end
44 44
 
45 45
     def strip(string)
46
-      puts string
47
-      string.strip! || string
46
+      (string || '').strip
48 47
     end
49 48
 
50 49
     def validate_options
@@ -54,7 +53,7 @@ module Agents
54 53
     def receive(incoming_events)
55 54
       incoming_events.each do |event|
56 55
         payload_interpolated = interpolated(event)
57
-        user_credentials = payload_interpolated['user_credentials'] || credential('boxcar_api_key')
56
+        user_credentials = payload_interpolated['user_credentials']
58 57
         post_params = {
59 58
           'user_credentials' => user_credentials,
60 59
           'notification' => {
@@ -72,11 +71,10 @@ module Agents
72 71
     def send_notification(post_params)
73 72
       response = HTTParty.post(API_URL, :query => post_params)
74 73
       raise StandardError, response['error']['message'] if response['error'].present?
75
-      if response['Response'].present?  and response['Response'] == "Not authorized"
74
+      if response['Response'].present?  && response['Response'] == "Not authorized"
76 75
         raise StandardError, response['Response']
77 76
       end
78
-      if not response['id'].present?
79
-        puts response
77
+      if !response['id'].present?
80 78
         raise StandardError, "Invalid response from Boxcar: #{response}"
81 79
       end
82 80
     end